package com.bdqn.systems.vo;

import lombok.Data;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;

/**
 * @author : CP
 * @version: 1.0
 * @program : xinguan-parent
 * @description : 菜单节点视图
 * @date : 2020-12-14 16:21
 **/
@Data
public class MenuNodeVO {
    /**
     * 菜单/按钮ID
     */
    private Long id;

    /**
     * 上级菜单ID
     */
    private Long parentId;

    /**
     * 菜单/按钮
     */
    private String menuName;

    /**
     * 菜单URL
     */
    private String url=null;

    /**
     * 图标
     */
    private String icon;

    /**
     * 排序
     */
    private Long orderNum;

    /**
     * 0:不展开，1：展开
     */
    private Integer open;

    /**
     * 是否禁用
     */
    private boolean disabled;

    /**
     * 权限标识
     */
    private String perms;

    /**
     * 类型 0菜单 1按钮
     */
    private Integer type;

    /**
     * 子菜单
     */
    private List<MenuNodeVO> children=new ArrayList<>();

    /*
     * 排序,根据order排序
     */
    public static Comparator<MenuNodeVO> order(){
        Comparator<MenuNodeVO> comparator = (o1, o2) -> {
            if(o1.getOrderNum() != o2.getOrderNum()){
                return (int) (o1.getOrderNum() - o2.getOrderNum());
            }
            return 0;
        };
        return comparator;
    }
}
